// JavaScript Document
	//模式窗口中指定此参数为true设置div框
	var contentPath = "/hr";
	var isModalWindow=false;
	var _listTable_preTr = null;
	var _listTable_preTrBgColor = null;
	var _doNotShowMessageNotice = false;
	$(document).ready(function(){
		var yy;
		if($.browser.msie){ 
			yy = document.compatMode == "CSS1Compat"? document.documentElement.clientHeight : document.body.clientHeight; 
		}else{ 
			yy = self.innerHeight; 
		}
		var isIE6Up = true;
		if(navigator.appName == "Microsoft Internet Explorer") 
		{
			if(navigator.appVersion.match(/MSIE 6./i)=='MSIE 6.') 
			{
				isIE6Up=false; 
			}
		}
		if(isIE6Up)
		{
			$("#body_div").height(yy-12);
			$("#body_content").height(yy-38);
			$(".divscroll").height(yy-90);
			if(isModalWindow)
			{
//				$("#body_div").css("width","99.5%");
				$("#body_content").height(yy-35);
				var ths = $(".body_title_text");
				
				$.each(ths, function(key, val) {
					parent.document.title = $(val).html();
					return false; 
				}); 

			}
		}
		else
		{
			$("#body_div").height(yy-8);
			$("#body_content").height(yy-38);
			$(".divscroll").height(yy-90);
//			$("#body_div").css("width","98.9%");
		}
		var queryDivHeight = $("#queryDiv").height();
		$("#queryDiv").height(queryDivHeight+12);
		_setTableWidth();
		//为listTable设置鼠标滑动行变色
		$(".listTable").find("tr").mouseover(function(){
			if(!$(this).find("td").hasClass("td_title"))
			{
				_listTable_preTr = this;
				_listTable_preTrBgColor = $(this).find("td").css("background-color");
				$(this).find("td").css("background-color","#FFFFC1");
			}
		});
		$(".listTable").find("tr").mouseout(function(){
			if(!$(this).find("td").hasClass("td_title"))
			{
				$(_listTable_preTr).find("td").css("background-color",_listTable_preTrBgColor);
				_listTable_preTr = null;
			}
		});
		//消息提醒功能
		var pageWidth = document.body.clientWidth;
/**		if(window.top.bottomFrame!=null&&isModalWindow==false&&_doNotShowMessageNotice==false&&pageWidth>400)
		{
			var msgCount_foot = window.top.bottomFrame.msgCount;
			var ignoreState_foot = window.top.bottomFrame.ignoreState;
			//没有消息，忽略本次登录消息，当前页不显示消息时不调用消息窗口
			if(msgCount_foot>0&&ignoreState_foot==false)
			{
				$.gritter.add({
					// (string | mandatory) the heading of the notification
					title: '消息提醒',
					// (string | mandatory) the text inside the notification
					text: '<a href="listMessage.do" target="mainFrame">您有'+msgCount_foot+'条未处理消息，点击进行查看</a><br/><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#" onclick="_hideNotice()">本次登录不再提醒</a>',
					image: contentPath+'/images/main/message.png',
					class_name: 'gritter-light'
				});
			}
		}**/
		if(typeof(xjSortTable)!="undefined")
		{
			//初始化listTable表格排序功能
			xjSortTable.initSortTable($(".listTable"),"td_title");
		}
	});
	function _hideNotice()
	{
		window.top.bottomFrame.ignoreState = true;
		$.gritter.removeAll();
	}
	//表单提交时出发方法，自动遮盖页面，显示等待区域，使用需手动调用此方法
	function _waitFormSubmiting()
	{
		$("#body_content").append("<a href='#waitingFormSubmit' class='nyroModal' id='nyroWaitFormSubmit' rev='modal'></a><div id='waitingFormSubmit' style='display:none;'>&nbsp;&nbsp;&nbsp;&nbsp;数据提交中，请稍候...</div>");
		$('#nyroWaitFormSubmit').nyroModal({
			sizes: {
				initW: 300,	// Initial width
				initH: 200,
				w : 300,
				h : 200
			}
		});
		$('#nyroWaitFormSubmit').nyroModal().nmCall();
		
	}
	function _closeFormSubmitingModal()
	{
		$('.nyroModalBg').parent().fadeOut("fast",function(){
			$('.nyroModalBg').parent().remove();
			$("#waitingFormSubmit").remove();
		});
	}
	//设置查询区的背景
  	function _queryDivBg(linkobj)
	{
		if($('#queryDiv').css("display")=="none")
		{
			nowId = "queryDiv";
			var offset = $(linkobj).offset();
			var offsetLeft = offset.left-500;
			if(offsetLeft<=0)
				offsetLeft = 10;
			$('#queryDiv').css({ 
				'left':offsetLeft, 
				'top':offset.top+20,
				'display':'block'
				});
			$('#queryDiv').offset().left=offset.left;
			$('#queryDiv').offset().top=offset.top+20;
			var isIE6Up = true;
			if(navigator.appName == "Microsoft Internet Explorer") 
			{
				if(navigator.appVersion.match(/MSIE 6./i)=='MSIE 6.') 
				{
					$('#queryDiv table').css({ 
						'left':"0px"
						});
				}
			}
			
		}
		else
		{
			$('#queryDiv').css("display","none");
		}
	}
	//影藏查询区
	function _cancelQuery(){
		$('#queryDiv').css("display","none");
	}
	//初始化框架页iframe的高度
	function _init_iFrame_height(iframeId)
	{
		if($.browser.msie){ 
			yy = document.compatMode == "CSS1Compat"? document.documentElement.clientHeight : document.body.clientHeight; 
		}else{ 
			yy = self.innerHeight; 
		}
		var isIE6Up = true;
		if(navigator.appName == "Microsoft Internet Explorer") 
		{
			if(navigator.appVersion.match(/MSIE 6./i)=='MSIE 6.') 
			{
				isIE6Up=false; 
			}
		}
		if(isIE6Up)
		{
			$("#"+iframeId).height(yy);
		}
		else
		{
			$("#"+iframeId).height(yy-5);
		}
	}
	//调整设置自动表格宽度的表格大小
	function _setTableWidth()
	{
		$(".tableAutoWidth").each(function(i){
			if($(this).attr("setWidth")=="true")
				return;
			if(parseInt($(this).css("width"))<parseInt($(this).attr("minWidth")))
			{
				var isIE6Up = true;
				if(navigator.appName == "Microsoft Internet Explorer") 
				{
					if(navigator.appVersion.match(/MSIE 6./i)=='MSIE 6.') 
					{
						isIE6Up=false; 
					}
				}
				//IE6以上全部应用最小宽度
				if(isIE6Up)
				{
					$(this).css("width",$(this).attr("minWidth")+"px");
					//alert($("#body_content").css("overflow"));
					$("#body_content").css("overflow","auto");
	//				if(isModalWindow==true)
	//					$("#body_content").height($("#body_content").height()-40);
				}
				else
				{
					//IE6一下不出现tab的情况下使用
					if(!$(this).hasClass("tabContent"))
					{
						$(this).css("width",$(this).attr("minWidth")+"px");
						//alert($("#body_content").css("overflow"));
						$("#body_content").css("overflow","auto");
					}
				}
				$(this).attr("setWidth","true");
			}
		});
	}
	
//调用模式窗口,长宽参数如果传入为0表示取屏幕的长宽
function ModalWindow(url, width, height) {
	if(width==0)
		width = window.screen.width-40;
	if(height==0)
		height=window.screen.height-130;
	var inf = "edge: Raised; center: Yes; help: Yes; resizable: no; status: No;dialogHeight:" + height + "px;dialogWidth:" + width + "px;scrolling:no";
	return showModalDialog(encodeURI(url) + "&width=" + width + "&height=" + height, window, inf);
}

var xjCommon = {
	/**
	 *	页面checkbox全选功能，传入checkbox名称
	 */ 
	checkAll : function (objName) {
		try {
			var checkedcount = 0;
			var checkObj = document.getElementsByName(objName);
			for (var i = 0; i < checkObj.length; i++) {
				if (checkObj[i].checked) {
					checkedcount++;
				}
			}
			if (checkedcount == checkObj.length) {
				for (var i = 0; i < checkObj.length; i++) {
					checkObj[i].checked = false;
				}
			} else {
				for (var i = 0; i < checkObj.length; i++) {
					checkObj[i].checked = true;
				}
			}
		}
		catch (ex) {
		}
	},
	/**
	 *	反回页面对象组的值，以指定分隔符进行连接
	 */ 
	getValueStr : function(objName,regex) {
		try {
				var str = "";
				var checkObj = document.getElementsByName(objName);
				for (var i = 0; i < checkObj.length; i++) {
					if (checkObj[i].checked) {
						str+=checkObj[i].value+regex;
					}
				}
				if(str.length>0)
					str=str.substring(0,str.length-1);
				return str;
			}
			catch (ex) {
			}
	},
	//格式化日期输入
	formatdate : function (varobj,e)
	{
	    var nc = window.event ? e.keyCode:e.which;
	    if(nc!=8||nc!=46)
	    {
	    	if(nc>=48 && nc<=57)
	    	{
		    	var i=0;
		    	var arrval=varobj.value.split("-");
		    	i=arrval.length;
		    	if(i<3)
		    	{
				    	if(varobj.value.length==4)
				    		varobj.value+="-";
				    	else
				    	if(varobj.value.length==7)
				    		varobj.value+="-";
		    	}
			}
	  		else
	  		{
	  			return false;
	  		}
	    }
	},
	/*
	控制tr行选中，变换背景色；
	需要在tr中添加onclick事件：<tr onClick="xjCommon.TrClick(this)" id="${obj.id}">
	*/
	varClkTr:null,   
	oldcolor:null,
	trClickUserFunc : function(){},
	TrClick : function(vartr)   
	{
		if(this.varClkTr!=null)   
	 	{   
	    	$(this.varClkTr).find("td").css("background-color",oldcolor);
			$(this.varClkTr).find("td").css("color","#1c459b");
		}
		oldcolor=$(vartr).find("td").css("background-color");
		$(vartr).find("td").css("background-color","#FEFFD6");
		$(vartr).find("td").css("color","#E63417");
		this.varClkTr=vartr;
		this.trClickUserFunc();
	},
	resetSubmitKey : function(formId)
	{
		var form = document.getElementById("formId");
		var submitKeyId = document.getElementsByName("xunj_submitKeyId");
		if(submitKeyId.length>0)
		{
			submitKeyId[0].value=parseInt(Math.random()*1000000+1);
		}
	}
	,setDataToClipboard : function(d){
		var tmp = parseInt(Math.random()*100000+1);
		$.ajax({
			type: "post",
			url: "setToClipboard.do?xjTmp="+tmp,
			data : encodeURI("data="+d)
		});
	}
	,getDataFromClipboard : function(callBackFuncName){
		var tmp = parseInt(Math.random()*100000+1);
		$.ajax({
			type: "get",
			url: "getFromClipboard.do?xjTmp="+tmp,
			success: function(data){
				eval(callBackFuncName+"('"+data+"')");
		   }
		});
	}
}
	function conversionUrl(path1,path2,width){
		var url='&width='+width;
		var url1;
		var url2;
		var str1;
		var str2;
		var elements1;
		var elements2;
		if(path1.indexOf("?")>1){
			url1 = path1.split("?");
			url+="&left.url="+url1[0];
			
			if(url1[1].indexOf("&")>1){
				elements1 = url1[1].split("&");
				for(var i=0;i<elements1.length;i++)
				{
					if(elements1[i].indexOf("=")>1)
					{
						str1 = elements1[i].split("=");
						url+="&left."+str1[0]+"="+str1[1];
					}
				}
			}else{
				if(url1[1].indexOf("=")>1)
				{
					str1 = url1[1].split("=");
					url+="&left."+str1[0]+"="+str1[1];
				}
			}
		}else{
			url+="&left.url="+path1;
		}
		if(path2.indexOf("?")>1){
			url2 = path2.split("?");
			url+="&right.url="+url2[0];
			
			if(url2[1].indexOf("&")>1){
				elements2 = url2[1].split("&");
				for(var i=0;i<elements2.length;i++)
				{
					if(elements2[i].indexOf("=")>1)
					{
						str2 = elements2[i].split("=");
						url+="&right."+str2[0]+"="+str2[1];
					}
				}
			}else{
				if(url2[1].indexOf("=")>1)
				{
					str2 = url2[1].split("=");
					url+="&right."+str2[0]+"="+str2[1];
				}
			}
		}else{
			url+="&right.url="+path2;
		}
		return url;
}
//调试信息输出
function _d(message)
{
	if(typeof window.console=="undefined")
	{
		if($("#xjMessageBox").length==0)
			$("body").append("<div id=\"xjMessageBox\" style=\"position:absolute;left:300px;top:300px;z-index:9999;\"></div>");
		$("#xjMessageBox").html(message);
	}
	else
	{
		console.log(message)
	}
}
//jquery 序列化扩展
(function ($) {
    var formJson = {};

    var addDom = function (dom) {
        var json = { Name: $(dom).attr('name'), Type: $(dom).attr('type'), Dom: $(dom) };
        formJson[$(dom).attr('name')] = json;
    };

    var getVal = function (dom) {
        var methods = {
            getDefaultVal: function (dom) {
                return $(dom).val();
            },
            getRadioVal: function (domName) {
                var doms = document.getElementsByName(domName);
                if (!doms) return '';
                for (var i = 0; i < doms.length; i++) {
                    if (doms[i].checked) return doms[i].value;
                }
                return '';
            },
            getCheckBoxVal: function (domName) {
                var val = '';
                var doms = document.getElementsByName(domName);
                if (!doms) return val;

                var index = 0;
                for (var i = 0; i < doms.length; i++) {
                    if (doms[i].checked) {
                        if (index == 0) {
                            val += doms[i].value;
                        }
                        else {
                            val += ',' + doms[i].value;
                        }
                        index++;
                    }
                }
                return val;
            }
        };

        var type = $(dom).attr('type');
        var domName = $(dom).attr('name');

        switch (type) {
            case 'text':
            case 'select-one':
            case 'select-multiple':
            case 'password':
            case 'hidden':
            case 'textarea':
                return methods.getDefaultVal(dom);
            case 'radio':
                return methods.getRadioVal(domName);
            case 'checkbox':
                return methods.getCheckBoxVal(domName);
            default:
                return '';
        }
    };

    $.fn.form_serialize = function () {
        var val = '';
        $(this).find('[name]').each(function () {
            addDom(this);
        });

        var index = 0;
        $.each(formJson, function () {
            var prefix = '&';
            if (index == 0) prefix = '';
            index++;
            val += prefix + this.Name + '=' + getVal(this.Dom);
        });
        return val;
    };
})(jQuery); 
	//将+替换成%2B
	function FixJqText(str) {
    var tempstr = str.replace(/\+/g, "%2B");
//    tempstr = tempstr.replace(/\&/g, "%26");
    return tempstr;
	}